package chapter13.section4;
//����13-5 �洢���̵���

import java.sql.*;

public class CallableStatementDemo {
    public static void main(String[] args) {
        String url = "jdbc:sqlserver://localhost:1433;" + "databaseName=bank;user=sa;password=123456;";
        Connection con = null;
        try {
            con = DriverManager.getConnection(url);
            String procName = "{?=call sumBalance(?,?)}";
            CallableStatement cstmt = con.prepareCall(procName);
            cstmt.setInt(2, 1000);
            cstmt.setInt(3, 10000);
            cstmt.registerOutParameter(1, Types.INTEGER);
            cstmt.execute();
            System.out.println(cstmt.getInt(1));
            cstmt.close();
            con.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
